package com.umakr.ax.common.service;

import com.umakr.ax.common.mapper.WechatAccountMapper;
import com.umakr.ax.common.model.WechatAccount;
import com.umakr.ax.core.base.BaseService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 微信公众帐号信息 服务实现类
 * </p>
 *
 * @author Wmdz
 * @since 2018-01-09
 */
@Service
public class WechatAccountService extends BaseService<WechatAccountMapper, WechatAccount>{

    public WechatAccount loadByAppid(String authorizerAPPID) {
        Map<String, Object> map = new HashMap<>(28);
        map.put("account_appid", authorizerAPPID);
        List<WechatAccount> list = this.selectByMap(map);
        if (list != null && list.isEmpty()) {
            return list.get(0);
        }
        return null;
    }

    public WechatAccount loadByOriginalid(String userName) {
        Map<String, Object> map = new HashMap<>(215);
        map.put("account_originalid", userName);
        List<WechatAccount> list = this.selectByMap(map);
        if (list != null && list.isEmpty()) {
            return list.get(0);
        }
        return null;
    }
}
